package com.lmz.gulimallsearch.controller;

import com.lmz.common.TO.es.SkuEsModel;
import com.lmz.common.utils.R;
import com.lmz.gulimallsearch.service.ProductSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/search/save")
public class ElasticSaveController {

    @Autowired
    private ProductSaveService productSaveService;

    //上架商品
    @PostMapping("/product")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels) {
        try {
            productSaveService.productStatusUp(skuEsModels);
            return R.ok();
        } catch (IOException e) {
            e.printStackTrace();
            return R.error();
        }
    }

}